/*--------------------------------------------------------------------------/
* @Author		KulerThemes.com http://www.kulerthemes.com
* @Copyright	Copyright (C) 2012 - 2013 KulerThemes.com. All rights reserved.
* @License		KulerThemes.com Proprietary License
/---------------------------------------------------------------------------*/

$(document).ready(function () {

	// Product hover
	$('#container .box .product-grid > div').hover(function () {
		var totalHeight = 0;
		$(this).find('.details').children().each(function() {
			totalHeight = totalHeight + $(this).outerHeight();
		});
		$(this).find('.details').outerHeight(totalHeight);
		$(this).css('marginBottom', -1 * totalHeight);
	}, function () {
		$(this).css('marginBottom', 0);
		$(this).find('.details').outerHeight(0);
	});

	// Setup mobile main menu
	$('#btn-mobile-toggle').toggle(
		function() {
			$(this).parent().removeClass('collapse').addClass('expand').find('.item').slideDown();
		},
		function() {
			$(this).parent().removeClass('expand').addClass('collapse').find('.item:not(.active)').slideUp();
		}
	);

	// Setup mobile tabs
	$('#btn-tabs-toggle').toggle(
		function() {
			$(this).parent().removeClass('collapse').addClass('expand').find('.ui-state-default').slideDown();
		},
		function() {
			$(this).parent().removeClass('expand').addClass('collapse').find('.ui-state-default:not(.ui-state-active)').slideUp();
		}
	);

	//Smooth scroll to on page element
	$(".review a").click(function(event){
		event.preventDefault();
		//calculate destination place
		var dest=0;
		if($(this.hash).offset().top > $(document).height()-$(window).height()){
			dest=$(document).height()-$(window).height();
		} else {
			dest=$(this.hash).offset().top;
		}
		//go to destination
		$('html,body').animate({scrollTop:dest}, 500,'swing');
     });

	// Smooth drop down for IE
	if ($.browser.msie) {
		
		// Main menu
		$('.primary-define .mainmenu li').hover(
			function() {
				$(this).find('.dropdown').slideDown(200);
			},
			function() {
				$(this).find('.dropdown').slideUp(200);
			}
		);

		// Mini cart
		$('.primary-define #header #cart').hover(
			function() {
				$(this).find('.inner').slideDown(200);
			},
			function() {
				$(this).find('.inner').slideUp(200);
			}
		);
	}

});